<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>按钮</button>
    <script>
        // 宏任务与微任务都属于事件队列中的任务,  先微后宏
        console.log(1);

        setTimeout(function(){
            console.log(2);
        },300)

        new Promise(function(resolve,reject){
            console.log(3);
            resolve()
        }).then(function(){
            console.log(4);
        }).finally(function(){
            console.log(5);
        })

        document.querySelector("button").onclick = function(){
            console.log(6);
        }

        console.log(7);





    </script>
</body>
</html>